package com.yunhe.task.client;

import com.yunhe.task.client.fallback.AuthorityFallbackFactory;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.Firm;
import com.yunhe.common.model.authority.Station;
import com.yunhe.common.model.company.Company;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author liuronglei
 */
@ApiIgnore
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityFallbackFactory.class)
public interface AuthorityClient {

    @RequestMapping(value = "/stations/{id}", method = RequestMethod.GET)
    ResultObject<Station> getStationById(@PathVariable("id") Long id);

    /**
     * 根据单位ID获得电站列表
     * @param firmId 单位ID
     */
    @RequestMapping(value = "/stations/byFirm/{firmId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<Station>>> getStationByFirmId(@PathVariable("firmId") Long firmId);

    /**
     * 根据单位代码获得单位
     * @param code 单位代码
     */
    @RequestMapping(value = "/firms/byCode/{code}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Firm>> getFirmByCode(@PathVariable("code") Long code);

    /**
     * 根据电站ID获得企业列表
     * @param stationId 电站ID
     */
    @RequestMapping(value = "/companys", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<Company>>> getCompanys(@RequestParam("stationId") Long stationId);
}
